package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.vo.DaoWalletDetailVO;
import com.sc.nft.enums.wallet.DaoWalletTypeEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.DaoWalletDetail;
import com.sc.nft.mapper.DaoWalletDetailMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * dao钱包明细表(sc_dao_wallet_detail)数据DAO
 *
 * @author zxy
 * @since 2023-12-16 19:17:50
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class DaoWalletDetailDao extends ServiceImpl<DaoWalletDetailMapper, DaoWalletDetail> {

    public Page<DaoWalletDetail> getByDaoId(Long daoId,Page page){
        LambdaQueryWrapper<DaoWalletDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DaoWalletDetail::getDaoId,daoId);
        wrapper.orderByDesc(DaoWalletDetail::getId);
        return page(page,wrapper);
    }
    public Page<DaoWalletDetail> getByDaoIdAndType(Long daoId, DaoWalletTypeEnum type, Page page){
        LambdaQueryWrapper<DaoWalletDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DaoWalletDetail::getDaoId,daoId);
        wrapper.eq(type!=null,DaoWalletDetail::getType,type);
        wrapper.orderByDesc(DaoWalletDetail::getId);
        return page(page,wrapper);
    }

     public  Page<DaoWalletDetail> getDaoWalletDetailPage(Long daoId,DaoWalletTypeEnum type, Date startTime, Date endTime, Page page){
        LambdaQueryWrapper<DaoWalletDetail> wrapper =new LambdaQueryWrapper<>();
         wrapper.eq(type!=null,DaoWalletDetail::getType,type);
         wrapper.eq(DaoWalletDetail::getDaoId,daoId);
         wrapper.ge(startTime!=null,DaoWalletDetail::getCreateTime,startTime);
         wrapper.le(endTime!=null,DaoWalletDetail::getCreateTime,endTime);
         wrapper.orderByDesc(DaoWalletDetail::getId);
         return page(page,wrapper);
     }
}